#define _CRT_SECURE_NO_WARNINGS 1
#include <vector>
#include <iostream>
using namespace std;
class Solution {
public:
    void moveZeroes(vector<int>& nums)
    {
        int l = 0;
        while (l < nums.size())
        {
            if (nums[l] == 0)
            {
                int r = l + 1;
                while (r < nums.size() && nums[r] == 0)
                {
                    ++r;
                }
                if (r >= nums.size()) return;
                //cerr<<"["<<l<<","<<r<<"]"<<endl;
                swap(nums[l], nums[r]);
            }
            ++l;
        }
    }
};